package api.txNative;

import android.content.Context;

import java.lang.ref.SoftReference;
import java.util.ArrayList;

import api.bean.API_TX_NativeBean;

/**
 * 原生自渲染模式
 */
public abstract class NativeAPI_TX {

    public static String clazz = "api.txNative.TX_Native";

    private static SoftReference<NativeAPI_TX> sf;

    public synchronized static NativeAPI_TX getInstance() {

        if (sf == null || sf.get() == null) {
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            if (o != null) {
                sf = new SoftReference<>((NativeAPI_TX)o);
                return (NativeAPI_TX)o;
            }
        }
        return sf == null ? null : sf.get();
    }

    public abstract void loadNative(Context context, int LoadCount,String NativePosID, LoadNativeCallBack callBack);
    public interface LoadNativeCallBack {
        void onNativeSuccessed(ArrayList<API_TX_NativeBean>gdtlist );
        void onNativeError(String code,String msg);
    }
}
